package ysc.cqnu.operdb.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ysc.cqnu.operdb.entity.Qinyou;
import ysc.cqnu.operdb.entity.ResultData;
import ysc.cqnu.operdb.mapper.QinYouMapper;
import ysc.cqnu.operdb.service.CheckQinYouInfoService;

@Service
public class CheckQinYouInfoServiceImpl implements CheckQinYouInfoService {
    @Autowired
    private ResultData resultData;
    @Autowired
    private Qinyou qinyouinfo;
    @Autowired
    private QinYouMapper qinYouMapper;

    @Override
    public ResultData checkQinYouInfoService(String qinyouname, String renwu, String yongtu, String juti, String uploader, String uploadDate) {
        try {
            qinyouinfo = qinYouMapper.chazhaoQinyouInfo(qinyouname,renwu,yongtu,juti,uploader,uploadDate);

            if(qinyouinfo!=null){
                int count = qinYouMapper.count();
                int site = qinYouMapper.qinyouInfoSite(String.valueOf(qinyouinfo.getId()));
                qinyouinfo.Count=String.valueOf(count);
                qinyouinfo.site=String.valueOf(site);
                resultData.flag="CheckSuccess";
                resultData.data=qinyouinfo;
                return resultData;
            }
            else {
                resultData.flag="QinyouInfoNoFind";
                resultData.data=null;
                return resultData;
            }
        }catch (Exception e){
            resultData.flag="CheckFail";
            resultData.data=null;
            return resultData;
        }
    }
}
